package com.example.zhugenew.adapter.newhouses;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.zhugenew.R;
import com.example.zhugenew.bean.newhouses.NewHouseBlockBean;

import java.util.ArrayList;
import java.util.List;

public class NewHouseBlockAdapter extends RecyclerView.Adapter<NewHouseBlockAdapter.ViewHolder> {
     private NewHouseBlockBean newHouseBlockBean;
     private Context context;

    public NewHouseBlockAdapter(NewHouseBlockBean newHouseBlockBean, Context context) {
        this.newHouseBlockBean = newHouseBlockBean;
        this.context = context;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.layout_newhouseblock_item, parent,false);
        return new ViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.title.setText(newHouseBlockBean.getData().get(position).getName());
        Glide.with(context).load(newHouseBlockBean.getData().get(position).getImgurl()).into(holder.imageView);
    }

    @Override
    public int getItemCount() {
        return newHouseBlockBean.getData().size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        private ImageView imageView;
        private TextView title;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            imageView=itemView.findViewById(R.id.iv_allhigh);
            title=itemView.findViewById(R.id.tv_allhigh_text);
        }
    }
}
 